package com.kelvin.oocl.scanner.impl;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import com.kelvin.oocl.pojo.CustomerVo;
import com.kelvin.oocl.scanner.DataScanner;

public class DataScannerImpl implements DataScanner{

	@Override
	public List<CustomerVo> scann(File file) throws FileNotFoundException {
		if(null==file){
			return null;
		}
		Scanner scanner = new Scanner(file);
		List<CustomerVo> list = new ArrayList<>();
		CustomerVo vo = null;
		while(scanner.hasNext()){
			vo = new CustomerVo();
			String line = scanner.nextLine().trim();
			String[] strs = line.split("\\s+");
			vo.setId(strs[0]);
			vo.setName(strs[1]);
			vo.setEmail(strs[2]);
			vo.setSex(strs[3]);
			vo.setBirthDate(strs[4]);
			list.add(vo);
		}
		scanner.close();
		return list;
	}
	
}
